package com.colter.project.data.structure.tree;

public class BinaryTree<T> {

	private T data;
	private BinaryTree<T> leftChild;
	private BinaryTree<T> rightChild;
	// private boolean visited = false;

	public BinaryTree() {

	}

	public BinaryTree(T data) {
		this.data = data;
		this.leftChild = null;
		this.rightChild = null;
	}

	public BinaryTree<T> getLeftChild() {
		return leftChild;
	}

	public BinaryTree<T> getRightChild() {
		return rightChild;
	}

	public void addLeftChild(BinaryTree<T> leftChild) {
		this.leftChild = leftChild;
	}

	public void addRightChild(BinaryTree<T> rightChild) {
		this.rightChild = rightChild;
	}

	public boolean isEmpty() {
		return data == null;
	}

	public void inOrder(BinaryTree<T> subTree) {
		if (subTree != null) {
			inOrder(subTree.leftChild);
			visit(subTree);
			inOrder(subTree.rightChild);
		}
	}

	private void visit(BinaryTree<T> subTree) {
		System.out.println(subTree);
	}

	@Override
	public String toString() {
		return "BinaryTree [data=" + data + "]";
	}

}
